<?php


Class ApiAction extends baseAction {

    var $path;
    var $DB_PREFIX;

    public function _initialize() {
        $this->path = "upload";
        $this->DB_PREFIX = C('DB_PREFIX');
    }

   
    public function get_tgroup($uid) {
        $map["id"] = $uid;
        $res=  D('user')->where($map)->getField('tgroup');
        return $res;
    }

   public function is_mobile($mobile) {
        if(preg_match("/^1[34578]{1}\d{9}$/",$mobile)){
        $res=1;
        }else{  
        $res=0;
        }  
        return $res;
    }
    public function has_agent($id) {
        $map["uid"] = $id;
        $res=  D('agent_log')->where($map)->getField('id');
        unset($map);
        $map["id"] = $id;
        $tgroup=  D('user')->where($map)->getField('tgroup');
        if($res||$tgroup!=0){
            $ret=1;
        }else{

            $ret=0;
        }
        return $ret;
    }


    public function successres($message = "操作成功",$ext='0') {

        $index["status"] = 1;

        $index["message"] = $message;
        
        $index["ext"] = $ext;

        $res = json_encode($index);

        echo $res;
        exit();
    }

    public function faileres($message = "获取失败",$ext='0') {

        $index["status"] = 0;

        $index["message"] = $message;
        
        $index["ext"] = $ext;

        $res = json_encode($index);

        echo $res;
        exit();
    }

}

?>
